package 数组Array.一维数组.test07;

public class ArrayTest07 {
    public static void main(String[] args) {
        Animal a1 = new Animal();
        Animal a2 = new Animal();
        Animal[] animals = {a1,a2};
        for (int i = 0; i < animals.length ; i++) {
            //Animal a = animals[i];
            //a.move();
            animals[i].move();
        }
        Animal[] a3 = new Animal[2];
        a3[0] = new Animal();
        //a3[1] = new Product();
        a3[1] = new Cat();
        a3[1].move();
        System.out.println("================================================");


        Animal[] anis = {new Cat(),new Bird()};
        for (int i = 0; i < anis.length ; i++) {
            if(anis[i] instanceof Cat){
                Cat c = (Cat)anis[i];
                c.catchMouse();
            }else if(anis[i] instanceof Bird){
                Bird b = (Bird)anis[i];
                b.sing();
            }

        }
    }
}
